/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86131
 * Date: 2023-11-22
 * Time: 15:15
 */
public class GoodsTest {
    public static void main(String[] args) {
        //1.创建一个数组
        Goods[] arr = new Goods[3];  //引用数据类型Goods,Goods表示一个类,这代表建的是一个储存对象的数组

        //2.创建三个商品对象
        Goods g1 = new Goods("001","华为p40",5999,100);
        Goods g2 = new Goods("002","保温杯",227,50);
        Goods g3 = new Goods("003","枸杞",12.7,70);

        //3.把商品添加到数组中
        arr[0] = g1;
        arr[1] = g2;
        arr[2] = g3;

        //4.遍历
        for(int i = 0;i< arr.length;i++){
            //i表示索引 arr[i]表示元素
            Goods goods = arr[i];
            System.out.println(goods.getId()+","+goods.getName()+","+goods.getPrice()+","+goods.getCount());
        }
    }
}
